<template>
  <div class="">
    <ul class="list">
      <li v-for="(item, index) in $store.state.list" :key="index">
        <input
          type="checkbox"
          v-model="$store.state.result"
          :value="item"
          @change="change"
        />
        <span>{{ item.title }}</span>
        <el-button class="remove" @click="remove(index)">删除</el-button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {},
  methods: {
    remove(index) {
      this.$store.commit("remove", index);
    },
    change() {
      this.$store.commit("change");
    },
  },
  components: {},
};
</script>

<style lang="scss">
.list {
  li {
    display: flex;
    height: 50px;
    align-items: center;
    border-bottom: 1px solid #000;
  }
  .remove {
    // margin-left: 300px;
    margin-left: auto;
    display: none;
  }
  li:hover {
    background: #ccc;
    .remove {
      display: block;
    }
  }
}
// 鼠标移上出现背景色和删除按钮
</style>
